/*package com.yiboshi.rehrs.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                // 允许对 Swagger 相关路径的访问需要身份验证
                .antMatchers("/docs.html", "/webjars/**", "/v2/api-docs", "/swagger-resources/**").authenticated()
                .anyRequest().permitAll() // 其他路径允许匿名访问
                .and()
                .httpBasic(); // 使用基本认证（弹出用户名和密码输入框）
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        // 配置内存中的用户信息
        auth.inMemoryAuthentication()
                .withUser("admin2025") // 用户名
                .password("admin@202503") // 密码（使用 {noop} 表示不加密）
                .roles("USER");
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        // 使用 NoOpPasswordEncoder（仅用于测试环境）
        return NoOpPasswordEncoder.getInstance();
    }
}

 */